home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / usrlib.txt < prev    next >
Text File  |  1995-03-31  |  22KB  |  664 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                     Instructions for MS-DOS program "USRLIB" 
  9.  
  10.        ***************************************************************** 
  11.                                      NOTICE 
  12.  
  13.        Hewlett-Packard is making the current preliminary version 2.2 of 
  14.        USRLIB.EXE available to customers free of charge to help them in 
  15.        HP 48SX application development, under the following conditions: 
  16.  
  17.        * The program USRLIB.EXE and the documentation file USRLIB.MAN are 
  18.        provided "as is," and are subject to change without notice. 
  19.        Hewlett-Packard Company make no warranty of any kind with regard 
  20.        to the software or documentation, including, but not limited to, 
  21.        the implied warranties of merchantability and fitness for a 
  22.        particular purpose.  Hewlett-Packard Company shall not be liable 
  23.        for any error or for incidental or consequential damages in 
  24.        connection with the furnishing, performance, or use of this 
  25.        software and documentation. 
  26.  
  27.        * The program and documentation are copyrighted by Hewlett- 
  28.        Packard.  Customers may freely reproduce and distribute this 
  29.        material.  Sale of this material is prohibited without prior 
  30.        written permission of Hewlett-Packard Company. 
  31.  
  32.        * The HP Customer Support department does not support the current 
  33.        version.  Questions, comments, defect reports, etc. should be 
  34.        directed to the Library Development conference on the HP 
  35.        Calculator Bulletin Board System.  All responses from Hewlett- 
  36.        Packard will normally be provided through that conference. 
  37.  
  38.        * Software converted into libraries by USRLIB.EXE should be tested 
  39.        and qualified in its library form.  Discrepancies between the 
  40.        execution of the libraries and the execution of the original 
  41.        source directory contents should be reported via the Bulletin 
  42.        Board. 
  43.  
  44.        Revised versions of the software and documentation will be posted 
  45.        on the Bulletin Board as they become available.  In particular, 
  46.        future versions will include less cryptic error messages, and 
  47.        better documention of the output listing information provided by 
  48.        the program. 
  49.  
  50.        Version 2.2 of the program USRLIB.EXE is a preliminary version of 
  51.        this software.  Software compiled into libraries using this 
  52.        program should be thoroughly tested in its library form prior to 
  53.        any reproduction or distribution to end users. 
  54.  
  55.        ***************************************************************** 
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.                                    -1- 
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.        1.  INTRODUCTION 
  75.  
  76.  
  77.        USRLIB.EXE is an MS-DOS executable file that creates an HP 48 
  78.        library object from an HP 48 directory.  A library is similar to a 
  79.        directory in that both are collections of named objects.  However, 
  80.        a directory normally resides in main RAM memory and is intended 
  81.        for continuous modification and execution, whereas a library 
  82.        contains objects intended for execution only, and can be used from 
  83.        ROM as readily as from RAM.  A directory's objects are organized 
  84.        in a linked list requiring a sequential search for access; a 
  85.        library contains an address table that provides rapid execution 
  86.        access to its individual objects. 
  87.  
  88.  
  89.        1.1  Glossary of Terms 
  90.  
  91.        Directory           HP48 directory object containing zero or more 
  92.                            variables. 
  93.  
  94.        Variable            A named object contained within a directory, 
  95.                            accessed by means of a global name. 
  96.  
  97.        Library             HP 48 library object containing zero or more 
  98.                            library commands.  Libraries include a text 
  99.                            title, a Library ID number, and optional 
  100.                            message tables and configuration code that is 
  101.                            executed at system halts. 
  102.  
  103.        Library command     A named object within a library, which is the 
  104.                            library analog of a directory's variable. 
  105.  
  106.        Global name         HP 48 global name object, execution of which 
  107.                            executes the object in the corresponding 
  108.                            (global) variable. 
  109.  
  110.        XLIB name           HP 48 XLIB name object, execution of which 
  111.                            executes the corresponding library command. 
  112.                            An XLIB name plays the role for libraries that 
  113.                            a global name plays for directories. 
  114.  
  115.        Library ID          A number in the range 0-7FFh that uniquely 
  116.                            identifies a library, and is used as an 
  117.                            argument for HP 48 commands that deal with 
  118.                            libraries as objects.  The following ranges 
  119.                            are defined for the ID numbers: 
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.                                    -2- 
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.                                   ID Range                    Purpose 
  141.                               Hex        Decimal 
  142.  
  143.                              0 - 100       0 - 256 
  144.                            101 - 200     257 - 512   HP ROM-Based Applications 
  145.                            201 - 300     513 - 768   HP RAM-Based Applications 
  146.                                                      Non-HP Applications 
  147.                                                      (numbers permanently 
  148.                                                      assigned by HP) 
  149.                            301 - 600    769 - 1536 
  150.                            601 - 6FF   1537 - 1792 
  151.                            700 - 7FF   1792 - 2047   HP 48SX Command Line Use 
  152.  
  153.  
  154.  
  155.        1.2  The Source Directory 
  156.  
  157.        USRLIB uses an HP 48 directory object as the source file to define 
  158.        the output library.  The source directory may contain any number 
  159.        of variables, each of which is converted to a library command in 
  160.        the output library (unless specified otherwise; see $VARS, 
  161.        $VISIBLE and $HIDDEN, below).  The objects in the variables are 
  162.        translated as necessary so that any global names in the objects 
  163.        that correspond to variables in the source directory are converted 
  164.        to XLIB names. 
  165.  
  166.        The source directory may contain subdirectories, but in that case 
  167.        the resulting library will not reflect the structure of the 
  168.        directory since a library structure is "flat."  If separate 
  169.        subdirectories contain variables with the same name, the uses of 
  170.        those names within the library will be correct, but the duplicated 
  171.        names will also be duplicated in the LIBRARY menu.  The names of 
  172.        the subdirectories themselves are not translated to library 
  173.        commands, and any use of those names in any of the other variables 
  174.        will result in an error during execution of USRLIB. 
  175.  
  176.        The directory may also include the following special variables: 
  177.  
  178.  
  179.        $ROMID      Contains a real or binary number object representing 
  180.                    the Library ID that is to be given to the library. 
  181.                    This can be overridden by specifying -r<romid> on the 
  182.                    command line.  The ID should be in the range 769 - 
  183.                    1792 (301h - 6FFh). 
  184.  
  185.                    The -r option must be specified from the command line 
  186.                    if no $ROMID is used. 
  187.  
  188.  
  189.        $TITLE      Contains a string to be used as the name of the 
  190.                    library.  This can be overridden by specifying -t<title> 
  191.                    on the command line.  The first (up to) 5 characters 
  192.  
  193.  
  194.  
  195.                                    -3- 
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.                    of the title are used for the LIBRARY menu label; the 
  208.                    first 22 characters are displayed by REVIEW. 
  209.  
  210.  
  211.        $CONFIG     Contains an object to be executed at configuration 
  212.                    time.  If no $CONFIG variable is present, no 
  213.                    configuration entry will be generated.  In the current 
  214.                    version of USRLIB, $CONFIG is also translated to a 
  215.                    library command; to prevent this, it $CONFIG should be 
  216.                    declared as hidden (see below). 
  217.  
  218.                    Note: the configuration code can generally NOT be 
  219.                    written in user-accessible commands.  Simple programs 
  220.                    such as << 123 ATTACH >> are OK, but more complicated 
  221.                    programs should take care to leave the stack 
  222.                    unchanged, and be sure NOT TO ERROR. 
  223.  
  224.  
  225.        $MESSAGE    Contains a list of names of variables that contain 
  226.                    strings to be combined into a message table. The 
  227.                    message numbers correspond to the list positions. 
  228.  
  229.                    If no $MESSAGE is present, no message table will be 
  230.                    generated. 
  231.  
  232.  
  233.        $VISIBLE    Contains a list of names of variables to be converted 
  234.                    to user-accessible library commands. 
  235.  
  236.                    By default, all variables will be translated to 
  237.                    library commands.  When the $VISIBLE list is present, 
  238.                    only the names in this list are used as XLIB name 
  239.                    table entries in the library. An empty list is 
  240.                    allowed, meaning that no XLIB name entries are 
  241.                    created. 
  242.  
  243.  
  244.        $HIDDEN     Contains a list of names of variables that are to be 
  245.                    converted to null-named objects in the library, and so 
  246.                    hidden from the library user. 
  247.  
  248.                    When the $HIDDEN list is present, those names listed 
  249.                    are not entered in the library XLIB name table.  If 
  250.                    both $VISIBLE and $HIDDEN are present, only the 
  251.                    $HIDDEN list will be used. 
  252.  
  253.  
  254.        $VARS       Contains a list of variables that should remain RAM- 
  255.                    based, i.e., the stored objects are not included in 
  256.                    the library, and no XLIB name entries are made for 
  257.                    their names.  All other variables in the source 
  258.  
  259.  
  260.  
  261.                                    -4- 
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.                    directory names are included as library commands. 
  274.  
  275.        Multiple instances are permitted of the declaration variables 
  276.        $VARS, $HIDDEN, and $VISIBLE variables, in various subdirectories 
  277.        of the source directory.  A particular variable is declared as a 
  278.        RAM variable, hidden, etc., if its name is entered in any of the 
  279.        relevant declaration variables anywhere in the current path 
  280.        defined by the variable's location. That is, a variable XXX found 
  281.        in any subdirectory will be hidden if XXX is in a list stored in 
  282.        $HIDDEN in the top level of the source directory; but YYY in the 
  283.        top level will not be hidden even if YYY is present in a $HIDDEN 
  284.        list in a subdirectory. 
  285.  
  286.        Not all program objects that execute correctly from global 
  287.        variables are directly convertible into libraries.  In general, no 
  288.        checks can be made for such errors, and USRLIB does not attempt to 
  289.        do so.  Here are some known pitfalls: 
  290.  
  291.           o Since a library cannot be modified, no library command may be 
  292.             the target of a STO or PUT operation. 
  293.  
  294.           o XLIB names are not usable in all contexts in which global 
  295.             names are valid arguments.  This can cause constructs that 
  296.             reference a named object to fail.  For example, 
  297.  
  298.                                       'A' 5 GETI 
  299.  
  300.             where A is a list will not work when A is converted to an 
  301.             XLIB name.  Instead use 
  302.  
  303.                                    'A' EVAL 5 GETI 
  304.  
  305.             or better yet 
  306.  
  307.                                       A 5 GETI 
  308.  
  309.             XLIB names are not valid as formal variables in algebraics, 
  310.             or as the independent variable for plotting or solving. 
  311.             Names intended to be used as such should be declared as 
  312.             global using $VARS or the -v option. 
  313.  
  314.           o ->STR applied to a global name that is converted to a 
  315.             ``hidden'' library command (see $HIDDEN) returns a null 
  316.             string. 
  317.  
  318.           o Embedded directories (entered as DIR...END) within lists and 
  319.             programs are not translated except for their first object. 
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                    -5- 
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.        1.3  Library Creation 
  340.  
  341.        The process of library creation and activation can be summarized 
  342.        as follows. 
  343.  
  344.       Item: 752 by vervalin at AUSTIN.LOCKHEED.COM 
  345. Author: Documentation by Paul Vervalin; BRIX by Andreas Gustafsson. 
  346.   Subj: BRIX decoded 
  347.   Keyw: CHIP48 BRIX 
  348.   Date: Sat Sep 15 1990 09:57  
  349.  
  350. Below is a detailed description of the BRIX game that is run with the CHIP48 
  351. interpreter.  I hope this helps others when writing programs using CHIP48. 
  352. All of this is hand typed so please forgive me if there are any typos.  
  353. Happy programming!! 
  354.   
  355.   register          contents 
  356. ---------------------------------------, 
  357.              to a variable in any convenient directory. 
  358.  
  359.          5.  Recall the library object from the variable to which it was 
  360.              transferred, and then store it in a RAM port (:n:x STO, 
  361.              where n is the port number, and x is any number).  After 
  362.              storing the library, you can purge the original copy in the 
  363.              variable to save memory. 
  364.  
  365.          6.  Turn the HP 48 off, then on.  This adds the new library to 
  366.              the system library table, and gives the library a chance to 
  367.              execute its own configuration program, if any.  (The HP 48 
  368.              will execute a system halt automatically at this stage, so 
  369.              you should save any stack objects or PICT first if you wish 
  370.              to recover them.)  The LIBRARY menu will now contain a menu 
  371.              entry labeled with the library's ID number in the PORTn 
  372.              submenu. 
  373.  
  374.          7.  Activate the directory in which you wish the library's 
  375.              commands to be accessible, then execute nnn ATTACH, where 
  376.              nnn is the library ID.  Any number of libraries can be 
  377.              attached to the HOME directory; subdirectories may have one 
  378.              library attached to each.  The main LIBRARY menu will now 
  379.              contain a menu key labeled by the library's title. 
  380.  
  381.        To remove a library, activate its associated directory and execute 
  382.        nnn DETACH.  Then execute :n:ID PURGE to remove the library from 
  383.        port n.  (You will notice a brief jump in the display when you 
  384.        execute the PURGE.  This is normal and harmless.) 
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.                                    -6- 
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.        2.  Instructions 
  408.  
  409.        (In the following, <bold> text represents user-supplied text.  Text 
  410.        appearing in brackets [ ] denotes optional entries. In actual 
  411.        entries, the [ ] should not be used.) 
  412.  
  413.        Syntax: 
  414.                USRLIB [-options] <dirfile> [ <libfile> [ <sumfile> ] ] 
  415.  
  416.  
  417.        <dirfile>   is the name of the source file, which must contain a 
  418.                  binary image of an HP48 directory or a backup object 
  419.                  containing a directory. 
  420.  
  421.        <Libfile>   is a file to contain the output library object. 
  422.  
  423.        <sumfile>   This is a textual summary of the names that were 
  424.                  translated.  The following information is given for each 
  425.                  object:  user name, type, offset into the <libfile> file, 
  426.                  XLIB numbers, whether it can be used in an algebraic, 
  427.                  and whether it is visible. 
  428.  
  429.                  Similarly, a list of message numbers and messages and a 
  430.                  summary of the space requirements is given. 
  431.  
  432.        <Sumfile> and the optional <listfile> (see OPTIONS below) may be 
  433.        redirected to stdout by using '-' for the output file name. 
  434.  
  435.  
  436.        2.1  Options 
  437.  
  438.        The following options may be included in the USRLIB command line: 
  439.  
  440.  
  441.        -d<listfile>  <listfile> will contain a text listing of the contents 
  442.                    of each object in the input directory. 
  443.  
  444.  
  445.        -h<header>    Use <header> for the library object header (for file 
  446.                    transfer). 
  447.  
  448.  
  449.        -l<listfile>  <listfile> will contain a text listing of the contents 
  450.                    of each object in the output library. Occurrances of 
  451.                    "ID'name'<--" indicate translation of an name (ID) 
  452.                    into an XLIB or a message table reference. 
  453.  
  454.  
  455.        -r<romid>     Set decimal Library ID (see $ROMID above). 
  456.  
  457.  
  458.  
  459.  
  460.  
  461.                                    -7- 
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.        -t<title>     Use <title> for the library title (see $TITLE above). 
  474.  
  475.  
  476.        -v<name>      Declare <name> as a RAM variable name (see $VARS above). 
  477.  
  478.  
  479.        2.2  Restrictions 
  480.  
  481.          1.  The total library output file cannot be larger than 128K 
  482.              bytes. 
  483.  
  484.          2.  Message strings must be less than 64K bytes each. 
  485.  
  486.  
  487.        2.3  Error Messages 
  488.  
  489.        In the following, words shown in parentheses within the quoted 
  490.        error messages represent values that indicate source-specific 
  491.        quantities. (path) represents the path within the source directory 
  492.        to the variable causing the error, in the form name1/name2/... , 
  493.        where the names are the subdirectoy names (on the HP 48SX, the 
  494.        path would be a list { name1 name2 ... }). 
  495.  
  496.  
  497.        2.3.1  General Errors 
  498.  
  499.        "Cannot allocate memory"  --memory is constantly being allocated 
  500.        for various compiler needs. 
  501.  
  502.        "Unexpected EOF on input"  --EOF was hit when more nibbles were 
  503.        expected. 
  504.  
  505.        "Can't malloc for decomp"  --can't get memory to create decompile 
  506.        information. 
  507.  
  508.  
  509.        2.3.2  Initialization/First Pass Errors 
  510.  
  511.        "USRLIB: Cannot open"  --The source file can not be opened. 
  512.  
  513.        "USRLIB: - not legal for input"  -- "-" (stdin) can't be used for 
  514.        input. 
  515.  
  516.        "Cannot alloc 128K bytes for image"  --Insufficient memory for the 
  517.        library image. 
  518.  
  519.        "ROMID must be in range 769 - 1792" 
  520.  
  521.        "Must have either -r romid or $ROMID"  --no library ID was 
  522.        specified. 
  523.  
  524.  
  525.  
  526.  
  527.                                    -8- 
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.        "Need either BAK of a directory or a directory" 
  540.  
  541.        "BAK object does not contain directory" 
  542.  
  543.        "Directory is empty" 
  544.  
  545.        "Object is not a string: (path)/$TITLE" 
  546.  
  547.        The next three messages may occur when ROMID is specified in the 
  548.        variable $ROMID. 
  549.  
  550.        "Illegal Real value for (path)/$ROMID: (value)" 
  551.  
  552.        "Illegal Binary value for (path)/$ROMID: (value)" 
  553.  
  554.        "Object not Real or Binary: (path)/$ROMID" 
  555.  
  556.        The next two messages may occur when a $CONFIG variable (or two) 
  557.        are specified. 
  558.  
  559.        "Object not program: (path)/$CONFIG" 
  560.  
  561.        "$CONFIG redefined: (path)/$CONFIG" 
  562.  
  563.        The next two messages may occur any time a string (variable name 
  564.        or message) isread. 
  565.  
  566.        "Variable name or message too long (>65535)" 
  567.  
  568.        "Out of memory: trying to malloc for string" 
  569.  
  570.        The next three messages may occur when a name list is being read. 
  571.        The $MESSAGE, $VISIBLE, $HIDDEN, and $VARS variables are all name 
  572.        lists. 
  573.  
  574.        "Object is not a list: (path)/name" 
  575.  
  576.        "Non-ID found in list:  (path)/name" 
  577.  
  578.        "Out of memory: (path)/name" 
  579.  
  580.        The next three messages occur during creation of and addition to 
  581.        internal name tables, and are variations of insufficient memory 
  582.        errors. 
  583.  
  584.        "Cannot malloc id table" 
  585.  
  586.        "Cannot malloc id entry: (path)/(name)" 
  587.  
  588.        "Cannot malloc id entry: (path)/(name)" 
  589.  
  590.  
  591.  
  592.  
  593.                                    -9- 
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.        2.3.3  Interim/Second Pass Errors 
  606.  
  607.        "Message object not found: (name)" 
  608.  
  609.        "Loss of object synchronism between passes: (path)/(name)"  -- 
  610.        (path)/(name) is replaced with the object where out-of-sync was 
  611.        discovered. 
  612.  
  613.        "Name must not exceed 16 characters: (path)/(name)"  --library 
  614.        object names are limited to 16 characters. 
  615.  
  616.        "Keyword cannot resolve to a directory: (path)/(name)"  -- 
  617.        Subdirectory names cannot be included in other directory objects' 
  618.        definitions. 
  619.  
  620.        The next two messages may occur as message objects (indicated in 
  621.        the $MESSAGE list) are being converted into a message table. 
  622.  
  623.        "Message object is not a string: (path)/(name)" 
  624.  
  625.        "Multiple definitions for message (path)/(name)" 
  626.  
  627.  
  628.        2.3.4  Clean-up/Write File Phase Errors 
  629.  
  630.        "Library image length is 0. 
  631.         LIB FILE NOT WRITTEN!" 
  632.  
  633.        "Max image size is 256K nibbles ... image is (value) nibbles. 
  634.         LIB FILE NOT WRITTEN!" 
  635.  
  636.        "Unsucessful write to library file"  --unknown error writing to library file. 
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.                                    -10- 
  660.  
  661.  
  662.  
  663.  
  664.